package com.minminaya.source;

public class Algorithm_8 {

    public static int numberOfOne1(int n) {
        int result = 0;

        for (int i = 0; i < 32; i++) {
            result += (n & 1);
            n >>= 1;
        }
        return result;
    }


    public static int numberOfOne2(int n) {

        int result = 0;
        while (n != 0) {
            result++;
            n = (n - 1) & n;
        }
        return result;
    }
}
